package cn.sunshine.framework.beans.factory;

import cn.sunshine.framework.beans.BeansException;

import java.util.Map;

/**
 * @Description Extension of the {@link BeanFactory} interface to be implemented by bean factories
 * that can enumerate all their bean instances, rather than attempting bean lookup
 * by name one by one as requested by clients. BeanFactory implementations that
 * preload all their bean definitions (such as XML-based factories) may implement
 * this interface.
 * <p>
 * 实现此接口规范有: 上下文是抽象具体还是通过 DefaultListable... 实现, 上下文是暴露给用户
 * ConfigurableListableBeanFactory: 约束 DefaultListableBeanFactory
 * ApplicationContext: 上下文环境支持
 * @Author Mokairui
 * @Since 2021/12/11
 */
public interface ListableBeanFactory extends BeanFactory {

    /**
     * 按照类型返回 Bean 实例
     * @param type
     * @param <T>
     * @return
     * @throws BeansException
     */
    <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;

    /**
     *
     * @return Return the names of all beans defined in this registry.
     */
    String[] getBeanDefinitionNames();

}
